package com.xiaoxiaoxt.xiaoxiaoxtdao.mapper;

import com.xiaoxiaoxt.xiaoxiaoxtdao.entity.Member;
import com.xiaoxiaoxt.xiaoxiaoxtdao.entity.Paper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public interface MemberMapper extends Mapper<Member> {
    //获取带role的用户信息
    Member selectAndRoleByPrimaryKey(Integer mid);
    //根据userid获取用户信息
    Member selectByUserId(@Param("userId") String userId);
    //根据token获取用户信息  即将废弃
    @Deprecated
    Member selectByToken(String token);

    ArrayList<Member> selectNameInPrimaryKey(List ids);

    ArrayList<Paper> getPaper(Integer mid);

    int updateMoneyByPrimaryKey(Member member);

    ArrayList<Member> selectInPrimaryKey(@Param("list") ArrayList<Integer> list);

    @Select("select m.* from dede_member m " +
            "left join mo_parent_children pc on pc.children_id = m.mid " +
            "where pc.parent_id = #{parentId,jdbcType=INTEGER}")
    ArrayList<Member> selectByParentId(@Param("parentId") Integer parentId);

    @Select("select count(*) from dede_member_home where pid = #{parentId,jdbcType=INTEGER} and  mid = #{childId,jdbcType=INTEGER}")
    int countByParentIdAndChildId(@Param("parentId") Integer parentId, @Param("childId") Integer childId);

    @Select("select * from dede_member")
    ArrayList<Member> selectAll();

    List<Map> selectTradeByMid(@Param("mid") Integer mid, @Param("subject") Integer subject, @Param("startTime") Long startTime, @Param("endTime") Long endTime);

    List<Map> selectRechargeByMid(@Param("mid") Integer mid, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
}